Add RTM_DELLINK handling to properly track device lifecycle. When a
device is deleted, update its state with flags=0 to mark it as not
present. This improves synchronization compared to only relying on
the hotplug handler.
Signed-off-by: Felix Fietkau <[email protected]>
struct ifinfomsg *ifi = NLMSG_DATA(nh);
struct nlattr *nla[__IFLA_MAX];
struct device *dev;
+ unsigned int flags;
- if (nh->nlmsg_type != RTM_NEWLINK)
+ if (nh->nlmsg_type != RTM_NEWLINK && nh->nlmsg_type != RTM_DELLINK)
return 0;
nlmsg_parse(nh, sizeof(struct ifinfomsg), nla, __IFLA_MAX - 1, NULL);
if (!dev)
return 0;
- system_device_update_state(dev, ifi->ifi_flags);
+ flags = (nh->nlmsg_type == RTM_DELLINK) ? 0 : ifi->ifi_flags;
+ system_device_update_state(dev, flags);
return 0;
}